package com.quyou.funtour.bean;

import lombok.Data;

@Data
public class ResultInfo {

    private ResultInfo(){}

    /** 返回状态*/
    private Boolean status;
    /** 返回码*/
    private Integer code;
    /** 返回信息*/
    private String message;
    /** 返回数据*/
    private Object data;

    private interface ResultCode{
        public static Integer SUCCESS = 200;
        public static Integer ERROR = 404;
        public static String SUCCESSMSG = "成功";
        public static String ERRORMSG = "失败";
    }

    public static ResultInfo ok(String msg, Object o){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setStatus(true);
        resultInfo.setCode(ResultCode.SUCCESS);
        resultInfo.setMessage(msg);
        resultInfo.setData(o);
        return resultInfo;
    }
    public static ResultInfo ok(String msg){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setStatus(true);
        resultInfo.setCode(ResultCode.SUCCESS);
        resultInfo.setMessage(msg);
        resultInfo.setData(null);
        return resultInfo;
    }
    public static ResultInfo ok(Object o){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setStatus(true);
        resultInfo.setData(o);
        resultInfo.setCode(ResultCode.SUCCESS);
        resultInfo.setMessage(ResultCode.SUCCESSMSG);
        return resultInfo;
    }
    public static ResultInfo ok(){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setStatus(true);
        resultInfo.setData(null);
        resultInfo.setCode(ResultCode.SUCCESS);
        resultInfo.setMessage(ResultCode.SUCCESSMSG);
        return resultInfo;
    }

    public static ResultInfo no(Object o){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setStatus(false);
        resultInfo.setData(o);
        resultInfo.setCode(ResultCode.ERROR);
        resultInfo.setMessage(ResultCode.ERRORMSG);
        return resultInfo;
    }

    public static ResultInfo no(String msg, Object o){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setStatus(false);
        resultInfo.setCode(ResultCode.ERROR);
        resultInfo.setMessage(msg);
        resultInfo.setData(o);
        return resultInfo;
    }
    public static ResultInfo no(String msg){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setStatus(false);
        resultInfo.setCode(ResultCode.ERROR);
        resultInfo.setMessage(msg);
        resultInfo.setData(null);
        return resultInfo;
    }
    public static ResultInfo no(){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setStatus(false);
        resultInfo.setCode(ResultCode.ERROR);
        resultInfo.setMessage(ResultCode.ERRORMSG);
        resultInfo.setData(null);
        return resultInfo;
    }

}
